#include"processBar.h"

//v1版本的调用
/*
int main()
{
  processbar();
  return 0;
}
*/

//v2版本
typedef void (*callback_t)(int);//函数指针类型


//模拟下载
void download(callback_t pb)
{
  int total = 1000;//总需要下载的资源为1000Mb
  int curr = 0; //当前下载0Mb

  while(curr<=total)
  {
    usleep(50000);
    int rate = curr*100/total;
    pb(rate);
    curr+=10;
  }
  printf("\n");
}

int main()
{
  printf("download1:\n");
  download(processbar);
  initbar();
  printf("download2:\n");
  download(processbar);
  initbar();
  printf("download3:\n");
  download(processbar);
  initbar();
  return 0;
}
